﻿@model EM.OA.Portal.Models.CarInfoModels
@{
    Layout = "~/Views/Shared/_LayoutContent.cshtml";
}

<link  type="text/css" href="~/Scripts/imageUpload/User.css" rel="stylesheet" />
<link type="text/css" href="~/Scripts/imageUpload/popup.css" rel="stylesheet" />
<link type="text/css" href="~/Scripts/imageUpload/imgareaselect/img/imgareaselect-animated.css" rel="stylesheet" />

<script type="text/javascript" src="~/Scripts/page/Car/CarInfo.js"></script>
    <script type="text/javascript" src="~/Scripts/imageUpload/jquery.form.js"></script>
    <script type="text/javascript" src="~/Scripts/imageUpload/imgareaselect/jquery.imgareaselect.pack.js"></script>
    <script type="text/javascript" src="~/Scripts/imageUpload/head.js"></script>
    <script type="text/javascript" src="~/Scripts/imageUpload/popup.js"></script>

<script type="text/javascript">

        $(document).ready(function () {
            $("#user_head_form").ajaxForm({
                success: function (data) {
                    $('#user_head_upload_box').show();
                    $('#user_head_show_box').hide();
                    if (data != undefined && data != null) {
                        if (data.msg == 0) {
                            showreward("<span class=\"g_error\">请上传图片！</span>");
                        } else if (data.msg == -1) {
                            showreward("<span class=\"g_error\">文件格式不对！</span>");
                        } else if (data.msg == -2) {
                            showreward("<span class=\"g_error\">上传图片不能超过10M！</span>");
                        } else if (data.msg == -3) {
                            showreward("<span class=\"g_error\">出现异常，请稍后再试！！</span>");
                        } else {
                            var path = "../UploadFiles/Images/temp/" + data.msg;
                            $("#head_name").val(data.msg);
                            
                            UserHeadUtil.initialize(path);

                        }
                    }
                }
            });
            $("#user_head_param_form").ajaxForm({
                success: function (data) {
                    if (data.msg == 0) {
                        showreward("<span class=\"g_error\">网络出现异常，请稍后再试！</span>");
                    } else if (data.msg == -1) {
                        showreward("<span class=\"g_error\">系统出现异常，请稍后再试！</span>");
                    } else {
                        showreward("<span class=\"g_ok\">修改成功！</span>");
                        $('img#user_head_origin').imgAreaSelect({ remove: true });
                        $("#CarPhote").val(data.msg);
                        $("#user_head_show_box").hide();
                        $("#user_head_upload_box").show();
                        $("#user_head_origin").attr({
                            "src": "../Images/upload.png",
                            "width": "100%",
                            "height": "100%"
                        });
                    }
                }
            });
        });

    </script>

<div>
    @*list*@
    <table id="list" class="easyui-datagrid" toolbar="#toolbar">
    </table>
    <div id="toolbar">
        <a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="add()">增加</a>
        <a href="#" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="edit()">修改</a>
        <a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="del()">删除</a>
        @*<div id="tb" style="padding: 3px">
            <span>@Html.LabelFor(m => m.WorkPlanName)</span>
            <input id="WorkPlanName" style="line-height: 26px; border: 1px solid #ccc">
            <span>@Html.LabelFor(m => m.WorkPlanType)</span>
            <input id="WorkPlanType" style="line-height: 26px; border: 1px solid #ccc">
            <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">Search</a>
        </div>*@
    </div>

    @*Detail*@
    <div id="dlg" class="easyui-dialog" style="width: 900px; height: 505px; padding: 10px"
        closed="true" buttons="#dlg-buttons" modal="true" resizable="true">
        <div id="dlg-buttons">
            <a href="#" class="easyui-linkbutton" iconcls="icon-ok" onclick="save()">保存</a>
            <a href="#" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
        </div>
        <div class="easyui-tabs" style="width: 850px; height: 421px">
            <div title="基础信息">
                <form id="fm" method="post">
                    @Html.HiddenFor(m => m.CarID)
                    <input name="CarPhote" id="CarPhote"  type="hidden" >
                    <table width="80%">
                        <tr>
                            <td>
                                @Html.LabelFor(m => m.CarNumber)
                            </td>
                            <td>
                                <input name="CarNumber" class="easyui-validatebox" data-options="required:true,validType:'length[1,10]'">
                            </td>
                            <td>
                                @Html.LabelFor(m => m.CarBrand)
                            </td>
                            <td>
                                <input name="CarBrand" class="easyui-validatebox" data-options="required:true,validType:'length[1,10]'">
                            </td>
                        </tr>
                        <tr>
                            
                            <td>
                                @Html.LabelFor(m => m.EngineCode)
                            </td>
                            <td>
                                <input name="EngineCode" class="easyui-validatebox" data-options="required:true,validType:'length[1,30]'">
                            </td>
                            <td>
                                @Html.LabelFor(m => m.Displacement)
                            </td>
                            <td>
                                <input name="Displacement" class="easyui-validatebox" data-options="required:true,validType:'length[1,30]'">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                @Html.LabelFor(m => m.CarKind)
                            </td>
                            <td>
                                <input name="CarKind" class="easyui-validatebox" data-options="required:true,validType:'length[1,10]'">
                            </td>
                            <td>
                                @Html.LabelFor(m => m.Capacity)
                            </td>
                            <td>
                                <input name="Capacity" class="easyui-numberbox" data-options="min:0,max:100" />
                            </td>
                        </tr>

                        <tr>
                            <td>
                                @Html.LabelFor(m => m.Price)
                            </td>
                            <td>
                                <input name="Price" class="easyui-numberbox" data-options="required:true,min:0,max:100" />
                            </td>
                            <td>
                                @Html.LabelFor(m => m.PurchaseDateTime)
                            </td>
                            <td>
                                <input class="easyui-datebox" id="PurchaseDateTime" name="PurchaseDateTime" data-options="required:true" />
                            </td>
                        </tr>
                        

                        <tr>
                            
                            <td>
                                @Html.LabelFor(m => m.Status)
                            </td>
                            <td colspan="3">
                                <select id="Status" name="Status" class="easyui-combobox" data-options="required:true,panelHeight:'auto'">
                                    <option value="0" selected="selected">可用</option>
                                    <option value="1">损坏</option>
                                    <option value="2">维修</option>
                                    <option value="3">报废</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                @Html.LabelFor(m => m.Remarks)
                            </td>
                            <td colspan="3">
                                @Html.TextAreaFor(m => m.Remarks, new { @style = "width:90%", @cols = "40", @rows = "8", @class = "easyui-validatebox" })
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
            <div title="上传图片">
                <div class="upbox clearfix">
                    <div class="upPhoto">
                        <div class="upcon" id="user_head_upload_box">
                            <p class="phototxt">选择你要上传的车辆图片</p>
                            <div class="upfile">
                                @using (Html.BeginForm("uploadHead", "CarInfo", FormMethod.Post, new { ID = "user_head_form", enctype = "multipart/form-data" }))
                                {
                                    <input type="file" name="head" class="filebtn" onchange="$('#user_head_upload_box').hide();$('#user_head_show_box').show();$('#user_head_form').submit();" />
                                    <input type="button" class="upimgbtn" value="上传图片" />						
                                }
                            </div>
                        </div>
                        <div id="user_head_show_box" style="width: 300px; height: 300px; line-height: 300px; text-align: center; background: gray no-repeat; margin-bottom: 10px; display: none">
                            <img id="user_head_origin" style="vertical-align: middle;" src="../Scripts/imageUpload/img/load.gif" />
                        </div>
                        <div class="sysbtn">
                            @using (Html.BeginForm("saveHead", "CarInfo", FormMethod.Post, new { ID = "user_head_param_form", enctype = "multipart/form-data" }))
                            {
                                @Html.HiddenFor(model => model.headFileName, new { id = "head_name" })
                                @Html.HiddenFor(model => model.x, new { id = "head_x" })
                                @Html.HiddenFor(model => model.y, new { id = "head_y" })
                                @Html.HiddenFor(model => model.width, new { id = "head_width" })
                                @Html.HiddenFor(model => model.height, new { id = "head_height" })                          
                                <input type="submit" class="btnyes" value="保存">
                                <input type="button" class="btnno" value="取消" onclick="cancelHead();">
                            }

                        </div>
                    </div>
                    <div class="upPhotolist clearfix">
                        <div class="upimg upbig">
                            <div class="upimgbox up_1">
                                <img src="../UploadFiles/Images/180/201305052304133099.jpg" style="width: 180px; height: 180px" id="user_head_180"/>
                            </div>
                            <p>图片尺寸180×180像素</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
